# 1.创建sokcet对象
import socket
socket_client = socket.socket()
# 2.连接到服务端(ip端口为元组)
socket_client.connect(("localhost",8888))
# 3. 发送消息
socket_client.send("hello my is client".encode("UTF-8"))
# 4. 接收消息
server_data = socket_client.recv(1024).decode("UTF-8")
print(server_data)
# 5.关闭连接
socket_client.close()